package cn.ncupyh.arrlist;

import cn.ncupyh.entity.Student;

import java.util.ArrayList;
import java.util.Iterator;

public class Collection2 {
    public static void main(String[] args) {
        //ArrayList<int> ints = new ArrayList<>();
        ArrayList<String> list = new ArrayList<>();
//        Student students = new Student(12345,"zhangsan",true);
//        Student student = new Student(12345,"zhangsan",true);
//        Student students = new Student(12345,"zhangsan",true);
        ArrayList<Student> students = new ArrayList<>();
        Student student1 = new Student(12345, "zhangsan", true);
        Student student2 = new Student(12345, "lisi", true);
        Student student3 = new Student(12369, "wanger", false);
        students.add(student1);
        students.add(student2);
        students.add(student3);
        list.add("zhangsan");
        list.add("lisi");
        list.add("wanger");
        //遍历,法一:
//        System.out.println("ID" + "\t" + "姓名" + "\t\t"+ "性别");
//        for (Student stu :students) {
//            System.out.println(stu.getStuId() + "\t" + stu.getStuName() + "\t" + stu.getStuGender() + "\n");
//        }

        //遍历,法二:
        Iterator<Student> stu = students.iterator();//获取Iterator对象
        while(stu.hasNext()){
            Student next = stu.next();
            System.out.println(next);
        }

    }
}
